const { DataTypes } = require('sequelize');
const { sequelize } = require('../utils/database');

const FeedComment = sequelize.define('FeedComment', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  user_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: '评论用户ID'
  },
  feed_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: '动态ID'
  },
  content: {
    type: DataTypes.TEXT,
    allowNull: false,
    comment: '评论内容'
  },
  parent_id: {
    type: DataTypes.INTEGER,
    allowNull: true,
    comment: '父评论ID，用于回复功能'
  },
  likes_count: {
    type: DataTypes.INTEGER,
    defaultValue: 0,
    comment: '点赞数量'
  },
  is_deleted: {
    type: DataTypes.BOOLEAN,
    defaultValue: false,
    comment: '是否已删除'
  }
}, {
  tableName: 'feed_comments',
  indexes: [
    {
      fields: ['user_id']
    },
    {
      fields: ['feed_id']
    },
    {
      fields: ['parent_id']
    },
    {
      fields: ['createdAt']
    }
  ]
});

module.exports = FeedComment; 